<template>
	<div class="house_main">
		<div class="mesg_tit">房屋管理中心</div>
		<div class="main_pdlr10">
			<el-form :inline="true" :model="formHouseSearch" class="houseFormMain ">
		        <el-form-item label="房屋地址">
		          <el-input v-model="formHouseSearch.hourseAddress"  style="width:300px;" placeholder="房屋地址"></el-input>
		        </el-form-item>
		        <el-form-item class="sear_btnbox">
		          <el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
		          
		        </el-form-item>
		    </el-form>
	      <el-table
	        :data="houseTable"
	        stripe
	        border
	        style="width: 100%"
					v-loading="loading">
	        <el-table-column
	          type='index'
	          label="序号"
	          align='center'
	          width="50">
	        </el-table-column>
	        <el-table-column
	          prop="address"
	          label="房屋地址"
	        >
	        </el-table-column>
	        
	         <el-table-column
	          prop="customerCount"
	          label="客户数"
	          width="70">
	        </el-table-column>
	       <el-table-column
	          prop="workOrderCount"
	          label="工单数"
	          width="70"
	          >
	        </el-table-column>
	        
	        <el-table-column
	          fixed='right'
	          width="70"
	          align='center'
	          label="操作">
	            <template slot-scope="scope">
	              <el-button
	                size="mini"
	                @click="handleLook(scope.$index, scope.row)">查看</el-button>
	             
	            </template>
	        </el-table-column>
	      </el-table>

	      
	      <div class="block">
	        <el-pagination
	            @size-change="handleSizeChange"
		        @current-change="handleCurrentChange"
		        :current-page.sync="currentPageHouse"
		        :page-sizes="[5, 10, 20, 30]"
		        :page-size="pageSizeHouse"
		        layout="sizes, prev, pager, next"
		        :total="totalHouse">
	        </el-pagination>
	      </div>
	  </div>
	

	</div>
</template>
<script>
import { getHouseList } from '@/api'
  export default {
    data() {
      return {
       	formHouseSearch: {//查询条件
          hourseAddress: ''
				},
				houseTable: [],
				loading: true,
				totalHouse: null,// 分页总条数
				pageSizeHouse:10, //当前分页一页多少条数
				currentPageHouse:1,//当前页数
      };
		},
		created () {
			let params = {
				query: this.formHouseSearch.hourseAddress,
				page:this.currentPageHouse,
				size:this.pageSizeHouse
			}
			this.HouseList(params)
		},
    methods:{
    	handleLook(index, row) {//查看房屋
				this.$router.push({
					path: '/home/housedetails',
					query: {
						houseId: row.houseId
					}
				})
			},
			onSubmit () {
				if (this.loading) {
          return
        }
				this.loading = true
				let params = {
					query: this.formHouseSearch.hourseAddress,
					page:this.currentPageHouse,
					size:this.pageSizeHouse
				}
				this.HouseList (params)
			},
			HouseList (params) {
				getHouseList(params).then(res => {
					let code = res.data.code
					if(code == 0){
						let data = res.data.data
						this.houseTable = data.list
						this.totalHouse = data.pageInfo.total
						this.loading = false
					}else if(code == 1){
						this.$message({
							message: res.data.msg
						})
					}
				})
			},
			handleSizeChange (val) { //改变每页的条数
				this.pageSizeHouse = val;
				this.currentPageHouse = 1
				let params = {
					query: this.formHouseSearch.hourseAddress,
					page: this.currentPageHouse,
					size: this.pageSizeHouse
		    }
		    this.HouseList(params);//调用查询接口
		  },
			handleCurrentChange (val) { //改变当前页
				this.currentPageHouse = val
				let params = {
					query: this.formHouseSearch.hourseAddress,
					page: this.currentPageHouse,
					size: this.pageSizeHouse
				}
				this.HouseList(params);//调用查询接口
			}
    }
  };
</script>
<style scoped>
 
</style>